'$INCLUDE: 'c:\bc7\programs\cyber\global.bi'

SUB DissolveScreen
    DIM ScreenPos%(2000)
    FOR X% = 1 TO 2000
        ScreenPos%(X%) = X%
    NEXT X%

    FOR X% = 1 TO 2000
        SWAP ScreenPos%(X%), ScreenPos%(INT(RND(1) * 2000) + 1)
    NEXT X%

    FOR X% = 1 TO 2000
        R% = ScreenPos%(X%) \ 80 + 1
        IF R% = 0 THEN R% = 1
        IF R% > 25 THEN R% = 25
        C% = ABS(ScreenPos%(X%) - (80 * R%))
        IF C% = 0 THEN C% = 1
        LOCATE R%, C%
        PRINT " ";
    NEXT X%

    LOCATE 1, 80: PRINT " ";   ' cheap temporary fix
END SUB

SUB Teletype
'speed of typing
    d! = 5

'if no delay, assign default
    IF d! < 1 THEN
       d! = 5
    END IF

'change delay to 100ths second
    d! = d! / 100

'print Text$ 1 char at a time, with a "click" after non-space characters

    FOR X% = 1 TO LEN(Text$)

        T$ = MID$(Text$, X%, 1)
        PRINT T$;
        IF T$ <> " " THEN
           SOUND 20000, 1
        END IF

'get current value of TIMER
        CurrentTimer! = TIMER

'delay appropriate time
        WHILE TIMER < (CurrentTimer! + d!)
        WEND

'stop delaying if a key is pressed
        IF INKEY$ <> "" THEN
           d! = 0
        END IF

    NEXT X%
END SUB

